home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / util / rexx / addressee.lha / addressee.rexx < prev    next >
OS/2 REXX Batch file  |  1996-10-21  |  9KB  |  280 lines

  1. /*  Final Writer Addressing Script.  */
  2.  
  3.  
  4.  
  5. /**************************************************
  6. *                                                 *
  7. *   History:                                      *
  8. *     Written 18 October by Andrew Bruno (c)      *
  9. *                                                 *
  10. *   Purpose:                                      *
  11. *     To add the addressee's name and address     *
  12. *     to the top of the letter and to print out   *
  13. *     and envelope if you want.                   *
  14. *                                                 *
  15. *                                                 *
  16. *   Notes:                                        *
  17. *     It is written for a "simple address",       *
  18. *     who's structure is shown below.             *
  19. *     Oh, and is ready to use for most Australian *
  20. *     addresses.                                  *
  21. *                                                 *
  22. *   Structure of files:                           *
  23. *     (example)                                   *
  24. *                                                 *
  25. *     Andrew Bruno                                *
  26. *     17/73-77 Frederick St.                      *
  27. *     Ashfield NSW                                *
  28. *     2131       (  <----- equ ZIP code)          *
  29. *                                                 *
  30. *     This is because the postcode is put on      *
  31. *     the bottom right corner in Australia,       *
  32. *     and so must be seperate from the other      *
  33. *     data so FW (and AREXX) can put it where     *
  34. *     it should be                                *
  35. *                                                 *
  36. *                                                 *
  37. *   Disclaimer:                                   *
  38. *     This is written as is.                      *
  39. *     If you like it, please tell me.             *
  40. *                                                 *
  41. *   Thanks:                                       *
  42. *     To all the people who helped me at the      *
  43. *     start when learning about reqtools and      *
  44. *     AREXX, etc.                                 *
  45. *                                                 *
  46. **************************************************/
  47.  
  48. /**************************************************
  49. *                                                 *
  50. *    These are the sizes of the envelopes         *
  51. *    that should be entered in the variables      *
  52. *    used by the script.                          *
  53. *                                                 *
  54. *                                                 *
  55. ***************************************************                                                 *
  56. *                                                 *
  57. *    Envelope sizes:                              *
  58. *    small- 14.5 x 9                              *
  59. *    medium - 16 x 11.5                           *
  60. *    big (wide) - 22 x 11                         *
  61. *    (add to this if you want)                    *
  62. *                                                 *
  63. *                                                 *
  64. **************************************************/
  65.  
  66. /* load the required library */
  67.  
  68. if ~show('L',"rexxreqtools.library") then do
  69.    if ~addlib('rexxreqtools.library',0,-30,0) then do
  70.       say 'reqtools library not available'
  71.       exit 10
  72.    end
  73. end
  74.  
  75. fonttag = ""
  76. NL = '0a'x
  77.  
  78. /*  local variables for use for envelope size:  */
  79.  
  80. lc = 0          /*    a counter        */
  81. telc = 0        /*    another counter  */
  82. normalfont = softsans
  83. normalsize = 12
  84. envprt = 0      /*  I do NOT want envelopes printed  */
  85.  
  86. /*
  87.     Start deletion block
  88.     please delete this little block, as I guess it will become
  89.     a little annoying after a while anyway.  :-)
  90. */
  91.  
  92. call rtezrequest( "This script will NOT print the" || NL ||,
  93.                   "envelope for you, it will" || NL ||,
  94.                   "ONLY prepare the page to print" || NL ||,
  95.                   "it.  Incase the printer is off", "Thanks")
  96.  
  97. /*  end deletion block  */
  98.  
  99. /* script lables */
  100.  
  101. pubscrname ="FinalWriterPubScreen"                  /* public screen name */
  102. startdir = "dh4:languages/arexx/fw/names"           /* start dir */
  103. startfile = ""                                      /* suggested filename */
  104. scrtag ="rt_pubscrname="||pubscrname
  105. pathtag = "rtfi_initialpath="||startdir
  106. postag = "rt_reqpos=reqpos_pointer"                 /* requester appears under pointer */
  107. hgttag = "rtfi_height="||200                        /* height of requester */
  108. matchtag = "rtfi_matchpat=~(#?.info)"               /* show only files that end in .txt, can also use '*'something */
  109. flagtag = "rtfi_flags=freqf_patgad"                 /* show the matchtag in the requester */
  110. bufftag = "rtfi_buffer=true"
  111. tags = scrtag pathtag postag hgttag matchtag flagtag bufftag
  112.  
  113. /* show the requester */
  114.  
  115. filename = rtfilerequest( , startfile,"Select a file","OK" ,tags)
  116.  
  117. /* check if user selected a file or cancelled */
  118.  
  119. if rtresult == 0 then                             /* user cancelled requester */
  120.   call cancelled
  121. else                                              /* user selected a file */
  122.   call selected
  123.  
  124. skip:
  125.  
  126. /*--------------------  exit point  ------------------*/
  127. exit
  128. /*--------------------  exit point  ------------------*/
  129.  
  130. cancelled:
  131. /* do here what you want if the requester is cancelled */
  132.   call rtezrequest("You didn't pick a file.", "No", , )
  133. return
  134.  
  135.  
  136. selected:
  137. /*  so here it all starts.  */
  138. call rtezrequest( "Do you want to" || NL ||,
  139.                   "print an envelope" || NL ||,
  140.                   "for this person?",,
  141.                   "_Yes|_No", , fonttag)              /* 1 = Yes, 0 = No */
  142. if result == 0 then envprt = 0
  143. else
  144. envprt = 1     /* sorry for the slack bit of coding here.  */
  145.  
  146.  
  147. /*  set up FW for default printing font / size  */
  148.  
  149. address 'FINALW.1'
  150.     Font normalfont
  151.     FontSize normalsize
  152.  
  153. call open('blah',filename,'R')
  154.  
  155. do until EOF('blah')
  156.     n1 = readln('blah')
  157.     address 'FINALW.1'
  158.         type n1
  159.         newparagraph
  160. end
  161.  
  162. call close('blah')
  163.  
  164. if envprt == 0 then
  165.     signal skip
  166. else
  167.  
  168. /*        Set up for printing the envelope.        */
  169.  
  170. /****************************************************
  171.     Ask for the size of the envelope
  172.     the person want to print on.
  173.     The resopnce is 1, 2 or 3 and stored in result.
  174. ****************************************************/
  175.  
  176. call rtezrequest( "Please select the envelope size" || NL ||,
  177.                   "you wish to use:" || NL ||,
  178.                   ""||NL||,
  179.                   "dimesnsions are shown as " || NL ||,
  180.                   "<--> / top to bottom" || NL ||,
  181.                   "1 - 14.5 x 9" || NL ||,
  182.                   "2 - 16 x 11.5" || NL ||,
  183.                   "3 - 22 x 11",,
  184.                   "_1|_2|_3", , fonttag)
  185.  
  186. if result = 1 then
  187.     call small
  188. else
  189. if result = 2 then
  190.     call medium
  191. else
  192.     call big
  193.  
  194. address 'FINALW.1'
  195.     new
  196.  
  197. wait 10                            /*  this is needed for FW to keep up with itself  */
  198.  
  199. /****************************
  200.  
  201. Set up FW for the "new"
  202. document with paper sizes etc.
  203.  
  204. ****************************/
  205.  
  206. address 'FINALW.2'
  207.     PageSetup PAGETYPE Custom Width ewidth Height eheight ORIENT Tall PAGES LeftRight PRINTERTYPE Sheetfed TOP 0.635 BOTTOM 0.635
  208.     SectionSetup Top tm Bottom 1
  209.     DisplayPrefs GUIDES pe RULERS All MEASURE Metric BUTTSTRIP 1 BUTTPOS Left INFOSTRIP On
  210.     Setmeasure ruler
  211.     Indent eindent
  212.     Font envfont
  213.     FontSize envfontsize
  214.     FontColor Black
  215. /*    View 130  */
  216.     type " "
  217.  
  218. do until telc = teln
  219.     address 'FINALW.2'
  220.         newparagraph
  221.     telc = telc + 1
  222.     end
  223.  
  224. call open('blah',filename,'R')
  225. do until lc = 3                                     /* 3 lines to be read in as normal!  */
  226.     n1 = readln('blah')
  227.         address 'FINALW.2'
  228.         type n1
  229.         newparagraph
  230.     lc = lc + 1
  231.     end                          /*  Now put in the post code in the bottom right corner  */
  232.     n1 = readln('blah')
  233.         address 'FINALW.2'
  234.         newparagraph
  235.         newparagraph
  236.         Indent pcindent
  237.         type n1
  238.  
  239. call close('blah')
  240.  
  241. return
  242.  
  243.  
  244. /*        the end of the script.  Tables follow.        */
  245.  
  246. small:
  247. envfont = Bandit_BoldItalic
  248. ewidth =        14.5     /* width of the envelope   */
  249. eheight =         9       /* height of the envelope  */
  250. eindent =         0       /* indent from left margin */
  251. pcindent =         6       /* indent for the postcode */
  252. envfontsize =    18       /* font size               */
  253. teln =             1       /* blank line count at top */
  254. tm =             1       /* top margin of text      */
  255. return
  256.  
  257. medium:
  258. envfont = Bandit_BoldItalic
  259. ewidth =        16       /* width of the envelope   */
  260. eheight =        11.5     /* height of the envelope  */
  261. eindent =         0       /* indent from left margin */
  262. pcindent =         8       /* indent for the postcode */
  263. envfontsize =    20       /* font size               */
  264. teln =             2       /* blank line count at top */
  265. tm =             2       /* top margin of text      */
  266. return
  267.  
  268. big:
  269. envfont = Bandit_BoldItalic
  270. ewidth =        22       /* width of the envelope   */
  271. eheight =        11       /* height of the envelope  */
  272. eindent =         2.5     /* indent from left margin */
  273. pcindent =        14       /* indent for the postcode */
  274. envfontsize =    20       /* font size               */
  275. teln =             2       /* blank line count at top */
  276. tm =             1       /* top margin of text      */
  277. return
  278.  
  279. /* end*/
  280.